<template>
  <section>
    <div>
      <el-input size="mini" v-model="widget.config.val" type="textarea" :id="widget.uuid" @click.native="focusEvent"/>
    </div>
  </section>
</template>

<script>
  import uuid from 'uuid'
  import Vue from 'vue'//后续添加属性，需要vue联动
  export default {
    name: "score-grade",
    props:['widget','mockData'],
    data(){
      return{
        targetList:[
          {name:'湿气',code:'shiqi'},
          {name:'木郁',code:'muyu'},
        ]
      }
    },
    watch:{
      widget(nv,ov){
        if(nv){
          this.init()
        }
      }
    },
    created(){
      this.init()
    },
    methods:{
      init(){
        if(!this.widget.data) Vue.set(this.widget,'data',{target:['shiqi']})
        // console.log('应该有啊------',this.mockData)
        if(this.mockData){
          this.widget.config={score:true,percentNum:true,grade:true,description:true}
        }
        if(!this.widget.uuid){
          this.widget.uuid=uuid()
        }
        setTimeout(()=>{
          this.setFocus(this.widget.checked)
        },100)
      },
      setFocus(checked){
        let tmp =document.getElementById(this.widget.uuid)
        if(checked) tmp.focus()
        else tmp.blur()
      },
      focusEvent(event){
        if(this.widget.checked){
          event.cancelBubble=true
        }
      }
    }
  }
</script>

<style scoped>

</style>
